//
//  FifthMusicTableViewCell.m
//  Project_B
//
//  Created by dllo on 15/12/1.
//  Copyright © 2015年 张闯. All rights reserved.
//

#import "FifthMusicTableViewCell.h"
#import "FifthVideoModel.h"
#import "UIImageView+WebCache.h"
#define CWIDTH self.contentView.frame.size.width
#define CHEIGHT self.contentView.frame.size.height

@interface FifthMusicTableViewCell ()

@property (nonatomic, strong) UILabel *title;
@property (nonatomic, strong) UILabel *intro;
@property (nonatomic, strong) UIImageView *image;


//@property (nonatomic, retain) UILabel *title;
//@property (nonatomic, retain) UILabel *intro;
//@property (nonatomic, retain) UIImageView *image;





@property (nonatomic, strong) UIImageView *timeImg;
@property (nonatomic, strong) UIImageView *countImg;
@property (nonatomic, strong) UILabel *timeLabel;


@end
@implementation FifthMusicTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.image = [[UIImageView alloc] init];
        [self.contentView addSubview:self.image];

        self.countImg = [[UIImageView alloc] init];
        [self.contentView addSubview:self.countImg];

        self.timeImg = [[UIImageView alloc] init];
        [self.timeImg setImage:[UIImage imageNamed:@"bofang"]];
        [self.contentView addSubview:self.timeImg];

        self.title = [[UILabel alloc] init];
        [self.contentView addSubview:self.title];
        
        self.intro = [[UILabel alloc] init];
        [self.contentView addSubview:self.intro];
        
        self.timeLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.timeLabel];
        
    }
    return self;
}


- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.image.frame = CGRectMake(10, 10, CWIDTH / 4, CHEIGHT - 20);
    self.title.frame = CGRectMake(self.image.frame.size.width + 20, self.image.frame.origin.y + 0, CWIDTH - 125, 35);
    self.title.font = [UIFont fontWithName:@"Helvetica" size:15];
    self.title.numberOfLines = 0;
    
    self.intro.frame = CGRectMake(self.title.frame.origin.x, self.title.frame.origin.y + self.title.frame.size.height + 3, CWIDTH - 130, 14);
    self.intro.font = [UIFont fontWithName:@"Helvetica" size:14];
    self.intro.textColor = [UIColor grayColor];
    
    self.timeImg.frame = CGRectMake(self.intro.frame.origin.x, self.intro.frame.origin.y + self.intro.frame.size.height + 10, 13, 13);
    self.timeLabel.frame = CGRectMake(self.timeImg.frame.origin.x + 13 + 5, self.timeImg.frame.origin.y, 100, 13);
    self.timeLabel.textColor = [UIColor grayColor];
    [self.timeLabel setFont:[UIFont systemFontOfSize:14]];
    

}

- (void)setModel:(FifthVideoModel *)model
{
    if (_model != model) {
        _model = model;
    }
    
    self.title.text = model.title;
    self.intro.text = model.intro;
    
    [self.image sd_setImageWithURL:[NSURL URLWithString:model.coverMiddle]];
    self.timeLabel.text = [NSString stringWithFormat:@"%.2f万", model.playsCounts.floatValue / 10000];
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
